/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package behaviourdiagram.impl;

import behaviourdiagram.Actuator;
import behaviourdiagram.BehaviourOutput;
import behaviourdiagram.BehaviourdiagramPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Actuator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link behaviourdiagram.impl.ActuatorImpl#getName <em>Name</em>}</li>
 *   <li>{@link behaviourdiagram.impl.ActuatorImpl#getOutput <em>Output</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActuatorImpl extends EObjectImpl implements Actuator {
	/**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
	protected static final String NAME_EDEFAULT = null;

	/**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
	protected String name = NAME_EDEFAULT;

	/**
   * The default value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getType()
   * @generated NOT
   * @ordered
   */
	protected static final String TYPE_EDEFAULT = null;

	/**
   * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getType()
   * @generated NOT
   * @ordered
   */
	protected String type = TYPE_EDEFAULT;

	/**
   * The cached value of the '{@link #getOutput() <em>Output</em>}' reference list.
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @see #getOutput()
   * @generated
   * @ordered
   */
	protected EList<BehaviourOutput> output;

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	protected ActuatorImpl() {
    super();
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	protected EClass eStaticClass() {
    return BehaviourdiagramPackage.Literals.ACTUATOR;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public String getName() {
    return name;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public void setName(String newName) {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BehaviourdiagramPackage.ACTUATOR__NAME, oldName, name));
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	public String getType() {
    return type;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	public void setType(String newType) {
    String oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BehaviourdiagramPackage.ACTUATOR__TYPE, oldType, type));
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	public EList<BehaviourOutput> getOutput() {
    if (output == null)
    {
      output = new EObjectWithInverseResolvingEList<BehaviourOutput>(BehaviourOutput.class, this, BehaviourdiagramPackage.ACTUATOR__OUTPUT, BehaviourdiagramPackage.BEHAVIOUR_OUTPUT__ACTUATOR);
    }
    return output;
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutput()).basicAdd(otherEnd, msgs);
    }
    return super.eInverseAdd(otherEnd, featureID, msgs);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated
   */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        return ((InternalEList<?>)getOutput()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__NAME:
        return getName();
      case BehaviourdiagramPackage.ACTUATOR__TYPE:
        return getType();
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        return getOutput();
    }
    return super.eGet(featureID, resolve, coreType);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__NAME:
        setName((String)newValue);
        return;
      case BehaviourdiagramPackage.ACTUATOR__TYPE:
        setType((String)newValue);
        return;
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        getOutput().clear();
        getOutput().addAll((Collection<? extends BehaviourOutput>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	@Override
	public void eUnset(int featureID) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__NAME:
        setName(NAME_EDEFAULT);
        return;
      case BehaviourdiagramPackage.ACTUATOR__TYPE:
        setType(TYPE_EDEFAULT);
        return;
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        getOutput().clear();
        return;
    }
    super.eUnset(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	@Override
	public boolean eIsSet(int featureID) {
    switch (featureID)
    {
      case BehaviourdiagramPackage.ACTUATOR__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case BehaviourdiagramPackage.ACTUATOR__TYPE:
        return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
      case BehaviourdiagramPackage.ACTUATOR__OUTPUT:
        return output != null && !output.isEmpty();
    }
    return super.eIsSet(featureID);
  }

	/**
   * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
   * @generated NOT
   */
	@Override
	public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", type: ");
    result.append(type);
    result.append(')');
    return result.toString();
  }

} //ActuatorImpl
